package com.rain.codemother.innderservie;

import com.rain.constant.UserConstant;
import com.rain.entity.User;
import com.rain.exception.BusinessException;
import com.rain.exception.ErrorCode;
import com.rain.vo.UserVo;
import jakarta.servlet.http.HttpServletRequest;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

public interface innerUserService {


    List<User> listByIds(Collection<? extends Serializable> ids);

    User getById(Serializable id);

    UserVo getUserVO(User user);

    static User getLoginUser(HttpServletRequest request){
        Object userObj = request.getSession().getAttribute(UserConstant.USER_LOGIN_STATE);
        User user= (User) userObj;
        if(user==null || user.getId()==null){
            throw new BusinessException(ErrorCode.NOT_LOGIN_ERROR);
        }
        return user;
    }

}
